s = input()
sk = ""


for i in s:
    if i in "([{<":
        sk = sk + i
    elif i in ")]}>":
        last = sk[-1]
        if i == ")" and last == "(":
            sk = sk[:-1]

        elif i == "]" and last == "[":
            sk = sk[:-1]

        elif i == "}" and last == "{":
            sk = sk[:-1]

        elif i == ">" and last == "<":
            sk = sk[:-1]


if sk == '':
    print(True)
else:
    print('NO')